#include <Map.h>
using namespace M_M_Map;
M_Map::M_Map(int cnt)
{
    NodeCnt=cnt;
    distance_M_Map=new double*[cnt];
    for(int i=0;i<cnt;i++){
        distance_M_Map[i]=new double[cnt];
        for(int j=0;j<cnt;j++){
            if(i==j){
                distance_M_Map[i][j]=0;
            }
            else{
                distance_M_Map[i][j]=M_M_Map_INF;
            }
        }
    }
}
    
M_Map::~M_Map()
{
    for(int i=0;i<NodeCnt;i++){
        delete distance_M_Map[i];
    }
    delete distance_M_Map;
}
void M_Map::addEdge(m_edge e){
    e.start_id=e.start_id-1;
    e.end_id=e.end_id-1;
    edges.insert(edges.begin(),e);
    distance_M_Map[e.start_id][e.end_id]=e.distance;
}

std::vector<m_edge> M_Map::getEdges(){
    return edges;
}

double** M_Map::getDistanceM_Map(){
    return distance_M_Map;
}

M_Map::M_Map(){
    ;
}
void M_Map::addNode(m_node n){
    nodes.insert(nodes.end(),n);
    NodeCnt=NodeCnt+1;
}

void M_Map::initialDistanceM_Map(){
    distance_M_Map=new double*[NodeCnt];
    for(int i =0;i<NodeCnt;i++){
        distance_M_Map[i]=new double[NodeCnt];
    }
}
m_node M_Map::findNode(double x,double y){

}
m_node M_Map::getNode(int nodeid){
    for(int i=0;i<nodes.size();i++){
        if (nodeid==nodes[i].node_id)
        {
            /* code */
            return nodes[i];
        }
    }
    m_node n_err;
    n_err.node_id=-1;
}
